#pragma once


/************************************************************/
/*  Author:			Michael Mozdzierz						*/
/*	Date:			01/25/2015								*/
/*	Description:	Create a depth buffer that has a 		*/
/*					depth stencil view and shader resource	*/
/*					view, for use as both.					*/
/*															*/
/************************************************************/

#include <D3D11.h>
#include "IGrahpicsResource.h"

class DepthBuffer : public IGraphicsResource
{
	ID3D11ShaderResourceView* srv = nullptr;

	ID3D11DepthStencilView* depth_view = nullptr;

	ID3D11Texture2D* depthBuffer = nullptr;

	unsigned int width = 0, 
		height = 0;

public:
	DepthBuffer(ID3D11Device* device, unsigned int width, unsigned int height);
	virtual ~DepthBuffer(void);	
	
	/////////////////////<Accessors/Mutators>//////////////////////////////////////////

	ID3D11DepthStencilView* getStencilView(void) const { return depth_view; }

	/////////////////////<Interface>//////////////////////////////////////////

	// copies data in video memory to CPU memory
	virtual void getData(void* data, unsigned int pixelStride) override;
	// copies resource data in CPU memory to video memory
	virtual void setData(void* data, unsigned int pixelStride) override;

	// gets the d3d11 object that represents the resource
	virtual ID3D11Resource* getResource(void) const { return (ID3D11Resource*)depthBuffer; }
	// gets shader resource view for this resource
	virtual ID3D11ShaderResourceView* getSrv(void) const { return srv; }

	// gets the d3d11 descriptor for this object and copies it onto 'desc'
	virtual void getDesc(void* desc) override { depthBuffer->GetDesc((D3D11_TEXTURE2D_DESC*)desc); }
};